home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * *
- * Startup example for "Startup.asm" version 3.4 *
- * *
- * © 1995, Kenneth C. Nilsen *
- * *
- * See bottom line! *
- * *
- *******************************************************************************
-
- StartSkip = 0 ;0=WB/CLI, 1=CLI only (eg. from AsmOne)
- Processor = 68000 ;0/680x0 (= 0 is faster than 68000)
- MathProc = 0 ;FPU: 0(none)/68881/68882/68040
-
-
- incdir inc: ;your include dir
- include Startup.asm ;our file
- *------------------------------------------------------------------------------
- *## here is our init section (Init: label and DefLib macro are required)
- *------------------------------------------------------------------------------
-
- dc.b "$VER: Example 1.45 (7.12.95)",0
- even
-
- Init: TaskName "Startup_test" ;set our task name
- TaskPri 1 ;set task pri
-
- DefLib intuition,0 ;open intuition.library ver. 0
- DefLib dos,37 ;open dos.library ver. 37
- DefEnd ;ALWAYS REQUIRED!!!
-
- *------------------------------------------------------------------------------
- ;## our main example code comes from here (Start: label is required!)
- *------------------------------------------------------------------------------
-
- Start: LibBase dos ;use dos.library base
-
- jsr -60(a6) ;Output()
- move.l d0,d1 ;copy handler
- beq.b .noOut ;null? then skip
-
- move.l #Text,d2 ;pointer to our text
- move.l #TextL,d3 ;length of text
- jsr -48(a6) ;Write() (to handler)
-
- *------------------------------------------------------------------------------
- ;## if we started from Wb then blink (just to differ a little)
- *------------------------------------------------------------------------------
-
- .noOut StartFrom ;a macro which tells you where the prg.
- beq.b .cli ;started from. (=0 cli / <>0 wb)
-
- .wb LibBase intuition ;use "LibBase" to get library bases
-
- *------------------------------------------------------------------------------
- ;## now intuition.library base is put into A6 and we can start using it:
- *------------------------------------------------------------------------------
-
- move.l 60(a6),a0 ;frontmost screen (hehe, wonder how?)
- jsr -96(a6) ;DisplayBeep(), blink the screen
-
- TaskPointer ;get pointer to this task in d0.
- ;use it what you want :)
- *------------------------------------------------------------------------------
- ;here we demostrade the argument parsing. You get one seperate argument by
- ;each time you use the "NextArg" macro. Pointer to argument [0] in d0 or NULL:
- *------------------------------------------------------------------------------
-
- .cli NextArg ;macro which gives us the pointer to
- beq.b .exit ;our arg. in D0 (or NULL in D0)
- ;Branch EQual if end of args.
- move.l d0,d2 ;we store pointer to buffer in D2
-
- *------------------------------------------------------------------------------
- ;## print arguments to default output (in cli) to see some actions:
- *------------------------------------------------------------------------------
-
- LibBase dos ;internal macro (dosbase in a6)
-
- jsr -60(a6) ;Output()
- move.l d0,d1 ;handler
- beq.b .exit ;no handler? then exit printing
-
- moveq #0,d3 ;length
- move.l d2,a0 ;copy buffer address to a0
- .count move.b (a0)+,d0 ;get one byte from buffer
- beq.b .gotLen ;found null, exit loop
- addq #1,d3 ;add one to length in D3
- bra.b .count ;count some more...
-
- .gotLen jsr -48(a6) ;Write(), print argument in cli
-
- jsr -60(a6) ;Output()
- move.l d0,d1 ;output handler in D1
- move.l #Text,d2 ;pointer to text/linefeed
- moveq #1,d3 ;length
- jsr -48(a6) ;Write(), print linefeed in cli
-
- bra.b .cli ;repeat until no args are left
-
- .exit Return 0 ;return code and bye bye!
-
- *-----------------------------------------------------------------------------*
- ;## Our data section for this example source:
- *-----------------------------------------------------------------------------*
-
- Text dc.b 10,'Startup.asm example 3.4',10
- dc.b 'Give some arguments to test the NextArg macro:',10,10
- TextL =*-Text
-
- *-----------------------------------------------------------------------------*
- *###### BOTTOM LINE
- *-----------------------------------------------------------------------------*
- ; Some assemblers like DevPac and Barfly will not accept spaces in
- ; macro names like the "Version" and "TaskName" macros. This works fine
- ; with the AsmOne assembler and I can't see why it shouldn't work with
- ; the others. If you notice this problem then do one of two things:
- ;
- ; 1) Use underscores in the "TaskName" name and don't use the "Version"
- ; macro.
- ; 2) Use none of these two macros.
- ;
- ; You can of course do this manually by looking at the Startup.asm file
- ; and see how this is done.
- ;
- ; Remember that supporting Workbench startup will make more people happy!
- ; :) (like that guy) and by using this startup code you have easy support
- ; for that AND extra features like reading arguments without having to
- ; parse the line, use ReadArgs(), or remove spaces and qvotes yourself.
- ; You can also easily make a version string into your binary programs and
- ; set your own task name. You have even control on where your program
- ; where started from. You can also prevent your program to crash on a
- ; machine with a lower processor than you require. The same thing about
- ; the FPU.
- ;
- ; The assembled startup code is in itself only about 1Kb! and that's
- ; worth making your program safe!
- ;
- ; Feel free to contact me if any problems occure or if you want features
- ; included. If you change the Startup.asm source it would be nice to see
- ; what you have done :)
- ;
- ; Add: kenneth@norconnect.no
- ;
- ; Digital Surface
- ; Attn: Kenneth Nilsen
- ; Kvernhusrenen 31
- ; N-5227 S-Neset
- ; Norway
-